import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _DataSet from "choerodon-ui/pro/lib/data-set";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
import _isUndefined from "lodash/isUndefined";
import _isNumber from "lodash/isNumber";
import _filter from "lodash/filter";
var _excluded = ["serverList"],
    _excluded2 = ["serverList"],
    _excluded3 = ["categoryCode"],
    _excluded4 = ["serverList"],
    _excluded5 = ["serverList"],
    _excluded6 = ["serverList"],
    _excluded7 = ["serverList"],
    _excluded8 = ["serverList"],
    _excluded9 = ["serverList"];

var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _class, _class2;

/**
 * sendConfig -  发送配置
 * @date: 2018-9-7

 */
import React, { Component } from 'react';
import { Card, Col, Form, Input, Row, Cascader } from 'antd';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import { Bind } from 'lodash-decorators';
import uuid from 'uuid/v4';
import { Content, Header } from 'components/Page';
import Lov from 'components/Lov';
import Switch from 'components/Switch';
import { Button as ButtonPermission } from 'components/Permission';
import intl from 'utils/intl';
import formatterCollections from 'utils/intl/formatterCollections';
import notification from 'utils/notification';
import { getCurrentOrganizationId, isTenantRoleLevel } from 'utils/utils';
import { CODE_UPPER } from 'utils/regExp';
import { DETAIL_CARD_CLASSNAME, DETAIL_CARD_TABLE_CLASSNAME, EDIT_FORM_CLASSNAME, EDIT_FORM_ITEM_LAYOUT, EDIT_FORM_ROW_LAYOUT, FORM_COL_3_LAYOUT } from 'utils/constants';
import TemplateDrawer from "./TemplateDrawer";
import ListTable from "./ListTable";
import Drawer from "./Drawer";
/**
 * 发送配置-行数据管理组件
 * @extends {Component} - React.Component
 * @reactProps {Object} [location={}] - 当前路由信息
 * @reactProps {Object} [match={}] - react-router match路由信息
 * @reactProps {!Object} sendConfig - 数据源
 * @reactProps {!boolean} fetchHeaderLoading - 数据加载是否完成
 * @reactProps {!boolean} createLoading - 新增是否完成
 * @reactProps {!boolean} updateLoading - 编辑是否完成
 * @reactProps {Object} form - 表单对象
 * @reactProps {Function} [dispatch=function(e) {return e;}] - redux dispatch方法
 * @return React.element
 */

var Detail = (_dec = connect(function (_ref) {
  var sendConfig = _ref.sendConfig,
      loading = _ref.loading;
  return {
    sendConfig: sendConfig,
    tenantRoleLevel: isTenantRoleLevel(),
    tenantId: getCurrentOrganizationId(),
    fetchHeaderLoading: loading.effects['sendConfig/fetchHeader'],
    createLoading: loading.effects['sendConfig/saveHeader'],
    updateLoading: loading.effects['sendConfig/updateHeader'],
    fetchTemplateLoading: loading.effects['sendConfig/fetchTemplateData'],
    fetchWebHookLoading: loading.effects['sendConfig/getWebhook'],
    deleteWebHookLoading: loading.effects['sendConfig/deleteWebhook']
  };
}), _dec2 = Form.create({
  fieldNameProp: null
}), _dec3 = formatterCollections({
  code: ['cmsg.sendConfig', 'entity.tenant', 'cmsg.common']
}), _dec4 = Bind(), _dec5 = Bind(), _dec6 = Bind(), _dec7 = Bind(), _dec8 = Bind(), _dec9 = Bind(), _dec10 = Bind(), _dec11 = Bind(), _dec12 = Bind(), _dec13 = Bind(), _dec14 = Bind(), _dec15 = Bind(), _dec16 = Bind(), _dec17 = Bind(), _dec18 = Bind(), _dec19 = Bind(), _dec20 = Bind(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = /*#__PURE__*/function (_Component) {
  _inherits(Detail, _Component);

  var _super = _createSuper(Detail);

  function Detail() {
    var _this;

    _classCallCheck(this, Detail);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));
    _this.state = {
      targetItem: {},
      // 表格中的一条记录
      templateDrawerVisible: false,
      // 模板模态框状态
      categoryMeaning: '',
      subcategoryMeaning: '',
      clearSelect: function clearSelect(e) {
        return e;
      }
    };
    _this.ds = new _DataSet({
      primaryKey: 'serverCode',
      autoCreate: true,
      fields: [{
        name: 'code',
        type: 'object',
        lovCode: 'CMSG.SERVER_WEBHOOK',
        multiple: true
      }],
      cacheSelection: true,
      selection: 'multiple',
      events: {
        update: _this.handleDataSetChange
      }
    });
    return _this;
  }

  _createClass(Detail, [{
    key: "componentDidMount",
    value:
    /**
     * render()调用后获取数据
     */
    function componentDidMount() {
      this.handleSearch();
    }
  }, {
    key: "handleSearch",
    value: function handleSearch() {
      var _this$props = this.props,
          dispatch = _this$props.dispatch,
          match = _this$props.match,
          _this$props$history$l = _this$props.history.location.payload,
          payload = _this$props$history$l === void 0 ? {} : _this$props$history$l;
      var isCopy = payload.isCopy,
          tempServerId = payload.tempServerId;
      var id = match.params.id;

      if (!_isUndefined(id) || isCopy) {
        dispatch({
          type: isCopy ? 'sendConfig/fetchCopyHeader' : 'sendConfig/fetchHeader',
          payload: {
            tempServerId: isCopy ? tempServerId : id
          }
        }).then(function (res) {
          if (res && isCopy) {
            var _res$serverList = res.serverList,
                serverList = _res$serverList === void 0 ? [] : _res$serverList,
                otherValues = _objectWithoutProperties(res, _excluded);

            var arr = serverList.map(function (item) {
              return _objectSpread(_objectSpread({}, item), {}, {
                tempServerLineId: "create-".concat(uuid())
              });
            });
            dispatch({
              type: 'sendConfig/updateState',
              payload: {
                copyDetail: _objectSpread({
                  serverList: arr
                }, otherValues)
              }
            });
          }
        });
      } else {
        dispatch({
          type: 'sendConfig/updateState',
          payload: {
            header: {}
          }
        });
      }

      dispatch({
        type: 'sendConfig/fetchType'
      });
      dispatch({
        type: 'sendConfig/queryMessageType'
      });
    }
    /**
     * 添加参数
     */

  }, {
    key: "handleAddLine",
    value: function handleAddLine() {
      this.setState({
        drawerVisible: true,
        targetItem: {}
      });
    }
    /**
     * 添加参数
     */

  }, {
    key: "handleDataSetChange",
    value: function handleDataSetChange(_ref2) {
      var value = _ref2.value,
          dataSet = _ref2.dataSet;
      this.handleAddWebHook(value);
      dataSet.reset();
    }
    /**
     * 保存
     */

  }, {
    key: "handleSave",
    value: function handleSave() {
      var _this$props2 = this.props,
          dispatch = _this$props2.dispatch,
          form = _this$props2.form,
          match = _this$props2.match,
          _this$props2$sendConf = _this$props2.sendConfig,
          _this$props2$sendConf2 = _this$props2$sendConf.header,
          header = _this$props2$sendConf2 === void 0 ? {} : _this$props2$sendConf2,
          _this$props2$sendConf3 = _this$props2$sendConf.copyDetail,
          copyDetail = _this$props2$sendConf3 === void 0 ? {} : _this$props2$sendConf3,
          tenantId = _this$props2.tenantId,
          tenantRoleLevel = _this$props2.tenantRoleLevel,
          _this$props2$history$ = _this$props2.history.location.payload,
          payload = _this$props2$history$ === void 0 ? {} : _this$props2$history$;
      var _payload$isCopy = payload.isCopy,
          isCopy = _payload$isCopy === void 0 ? false : _payload$isCopy;

      var _header$serverList = header.serverList,
          serverList = _header$serverList === void 0 ? [] : _header$serverList,
          otherValues = _objectWithoutProperties(header, _excluded2);

      var _this$state = this.state,
          categoryMeaning = _this$state.categoryMeaning,
          subcategoryMeaning = _this$state.subcategoryMeaning;
      form.validateFields(function (err, values) {
        if (!err) {
          var anotherParameters = (isCopy ? copyDetail.serverList : serverList).map(function (item) {
            return _objectSpread(_objectSpread({}, item), {}, {
              tempServerLineId: item.tempServerLineId && item.tempServerLineId.toString().startsWith('create-') ? '' : item.tempServerLineId
            });
          });

          var categoryCode = values.categoryCode,
              rest = _objectWithoutProperties(values, _excluded3);

          var params = _objectSpread(_objectSpread({}, rest), {}, {
            categoryCode: categoryCode[0],
            subcategoryCode: categoryCode[1],
            tenantId: tenantRoleLevel ? tenantId : values.tenantId
          });

          if (_isUndefined(match.params.id) || isCopy) {
            dispatch({
              type: 'sendConfig/saveHeader',
              // 新增逻辑
              payload: {
                dto: _objectSpread(_objectSpread({
                  serverList: _toConsumableArray(anotherParameters)
                }, params), {}, {
                  categoryMeaning: categoryMeaning || header.categoryMeaning,
                  subcategoryMeaning: subcategoryMeaning || header.subcategoryMeaning
                })
              }
            }).then(function (res) {
              if (res) {
                notification.success();
                dispatch(routerRedux.push({
                  pathname: "/cmsg/send-config/detail/".concat(res.tempServerId)
                }));
              }
            });
          } else {
            dispatch({
              type: 'sendConfig/updateHeader',
              // 更新逻辑
              payload: {
                tempServerId: header.tempServerId,
                dto: _objectSpread(_objectSpread(_objectSpread({
                  serverList: _toConsumableArray(anotherParameters)
                }, otherValues), params), {}, {
                  categoryMeaning: categoryMeaning || header.categoryMeaning,
                  subcategoryMeaning: subcategoryMeaning || header.subcategoryMeaning
                })
              }
            }).then(function (res) {
              if (res) {
                notification.success();
                dispatch({
                  type: 'sendConfig/updateState',
                  payload: {
                    header: res
                  }
                });
              }
            });
          }
        }
      });
    }
    /**
     * 参数列表- 行编辑
     * @param {object} record - 规则对象
     */

  }, {
    key: "handleEditContent",
    value: function handleEditContent(record) {
      this.setState({
        drawerVisible: true,
        targetItem: _objectSpread({}, record)
      });
      this.handleFetchWebHook(record);
    }
    /**
     * 参数列表- 行编辑
     * @param {object} record - 规则对象
     */

  }, {
    key: "handleFetchWebHook",
    value: function handleFetchWebHook(record) {
      var _this2 = this;

      if (_isNumber(record.objectVersionNumber) && record.typeCode === 'WEB_HOOK') {
        var _this$props3 = this.props,
            dispatch = _this$props3.dispatch,
            tenantId = _this$props3.tenantId,
            tenantRoleLevel = _this$props3.tenantRoleLevel,
            getFieldValue = _this$props3.form.getFieldValue;
        this.ds.getField('code').setLovPara('tenantId', tenantRoleLevel ? tenantId : getFieldValue('tenantId'));
        this.ds.getField('code').setLovPara('tempServerLineId', record.tempServerLineId);
        dispatch({
          type: 'sendConfig/getWebhook',
          payload: _objectSpread({}, record)
        }).then(function (res) {
          if (res) {
            _this2.state.clearSelect();
          }
        });
      }
    }
  }, {
    key: "getRef",
    value: function getRef(clearSelect) {
      this.setState({
        clearSelect: clearSelect
      });
    }
    /**
     * 参数列表- 行删除
     * @param {obejct} record - 规则对象
     */

  }, {
    key: "handleDeleteContent",
    value: function handleDeleteContent(record) {
      var _this3 = this;

      var _this$props4 = this.props,
          dispatch = _this$props4.dispatch,
          _this$props4$sendConf = _this$props4.sendConfig,
          _this$props4$sendConf2 = _this$props4$sendConf.header,
          header = _this$props4$sendConf2 === void 0 ? {} : _this$props4$sendConf2,
          copyDetail = _this$props4$sendConf.copyDetail,
          _this$props4$history$ = _this$props4.history.location.payload,
          payload = _this$props4$history$ === void 0 ? {} : _this$props4$history$;
      var isCopy = payload.isCopy;

      var _header$serverList2 = header.serverList,
          serverList = _header$serverList2 === void 0 ? [] : _header$serverList2,
          otherValues = _objectWithoutProperties(header, _excluded4);

      var _copyDetail$serverLis = copyDetail.serverList,
          copyServerList = _copyDetail$serverLis === void 0 ? [] : _copyDetail$serverLis,
          otherCopyValues = _objectWithoutProperties(copyDetail, _excluded5);

      var recordTempServerLineId = record.tempServerLineId;

      if (!isCopy && !recordTempServerLineId.toString().startsWith('create-')) {
        dispatch({
          type: 'sendConfig/deleteLine',
          payload: _objectSpread({}, record)
        }).then(function (res) {
          if (res) {
            notification.success();

            _this3.handleSearch();
          }
        });
      } else if (isCopy) {
        // 删除的操作
        var newParameters = _filter(copyServerList, function (item) {
          return recordTempServerLineId !== item.tempServerLineId;
        });

        dispatch({
          type: 'sendConfig/updateState',
          payload: {
            copyDetail: _objectSpread({
              serverList: _toConsumableArray(newParameters)
            }, otherCopyValues)
          }
        });
      } else {
        // 删除的操作
        var _newParameters = _filter(serverList, function (item) {
          return recordTempServerLineId !== item.tempServerLineId;
        });

        dispatch({
          type: 'sendConfig/updateState',
          payload: {
            header: _objectSpread({
              serverList: _toConsumableArray(_newParameters)
            }, otherValues)
          }
        });
      }
    }
    /**
     * 新增滑窗保存操作
     * @param {object} values - 保存数据
     */

  }, {
    key: "handleSaveContent",
    value: function handleSaveContent(values) {
      var _this$props5 = this.props,
          dispatch = _this$props5.dispatch,
          _this$props5$sendConf = _this$props5.sendConfig,
          _this$props5$sendConf2 = _this$props5$sendConf.header,
          header = _this$props5$sendConf2 === void 0 ? {} : _this$props5$sendConf2,
          _this$props5$sendConf3 = _this$props5$sendConf.copyDetail,
          copyDetail = _this$props5$sendConf3 === void 0 ? {} : _this$props5$sendConf3,
          _this$props5$history$ = _this$props5.history.location.payload,
          payload = _this$props5$history$ === void 0 ? {} : _this$props5$history$;
      var isCopy = payload.isCopy;

      var _header$serverList3 = header.serverList,
          serverList = _header$serverList3 === void 0 ? [] : _header$serverList3,
          otherValues = _objectWithoutProperties(header, _excluded6);

      var _copyDetail$serverLis2 = copyDetail.serverList,
          copyServerList = _copyDetail$serverLis2 === void 0 ? [] : _copyDetail$serverLis2,
          otherCopyValues = _objectWithoutProperties(copyDetail, _excluded7);

      var value = _objectSpread({
        tempServerLineId: "create-".concat(uuid())
      }, values);

      dispatch({
        type: 'sendConfig/updateState',
        payload: {
          header: _objectSpread({
            serverList: [].concat(_toConsumableArray(serverList), [value])
          }, otherValues)
        }
      });

      if (isCopy) {
        dispatch({
          type: 'sendConfig/updateState',
          payload: {
            copyDetail: _objectSpread({
              serverList: [].concat(_toConsumableArray(copyServerList), [value])
            }, otherCopyValues)
          }
        });
      }

      this.setState({
        drawerVisible: false,
        targetItem: {}
      });
    } // 编辑保存滑窗

  }, {
    key: "handleEditOk",
    value: function handleEditOk(values) {
      var _this$props6 = this.props,
          dispatch = _this$props6.dispatch,
          _this$props6$sendConf = _this$props6.sendConfig,
          _this$props6$sendConf2 = _this$props6$sendConf.header,
          header = _this$props6$sendConf2 === void 0 ? {} : _this$props6$sendConf2,
          _this$props6$sendConf3 = _this$props6$sendConf.copyDetail,
          copyDetail = _this$props6$sendConf3 === void 0 ? {} : _this$props6$sendConf3,
          _this$props6$history$ = _this$props6.history.location.payload,
          payload = _this$props6$history$ === void 0 ? {} : _this$props6$history$;
      var isCopy = payload.isCopy;

      var _header$serverList4 = header.serverList,
          serverList = _header$serverList4 === void 0 ? [] : _header$serverList4,
          otherValues = _objectWithoutProperties(header, _excluded8);

      var _copyDetail$serverLis3 = copyDetail.serverList,
          copyServerList = _copyDetail$serverLis3 === void 0 ? [] : _copyDetail$serverLis3,
          otherCopyValues = _objectWithoutProperties(copyDetail, _excluded9);

      var newList = serverList.map(function (item) {
        if (item.tempServerLineId === values.tempServerLineId) {
          return _objectSpread(_objectSpread({}, item), values);
        }

        return item;
      });
      var newCopyList = copyServerList.map(function (i) {
        if (i.tempServerLineId === values.tempServerLineId) {
          return _objectSpread(_objectSpread({}, i), values);
        }

        return i;
      });
      dispatch({
        type: 'sendConfig/updateState',
        payload: {
          header: _objectSpread({
            serverList: newList
          }, otherValues)
        }
      });

      if (isCopy) {
        dispatch({
          type: 'sendConfig/updateState',
          payload: {
            copyDetail: _objectSpread({
              serverList: newCopyList
            }, otherCopyValues)
          }
        });
      }

      this.setState({
        drawerVisible: false,
        targetItem: {}
      });
    } //

  }, {
    key: "handleAddWebHook",
    value: function handleAddWebHook(payload) {
      var _this4 = this;

      var dispatch = this.props.dispatch;
      var targetItem = this.state.targetItem;
      dispatch({
        type: 'sendConfig/createWebhook',
        payload: {
          tempServerLineId: targetItem.tempServerLineId,
          payload: payload.map(function (item) {
            return _objectSpread(_objectSpread({}, item), {}, {
              tempServerId: targetItem.tempServerId
            });
          })
        }
      }).then(function (res) {
        if (res) {
          notification.success();

          _this4.handleFetchWebHook(targetItem);
        }
      });
    }
  }, {
    key: "handleDeleteWebHook",
    value: function handleDeleteWebHook(payload) {
      var _this5 = this;

      var dispatch = this.props.dispatch;
      var targetItem = this.state.targetItem;
      dispatch({
        type: 'sendConfig/deleteWebhook',
        payload: {
          tempServerLineId: targetItem.tempServerLineId,
          payload: payload.map(function (item) {
            return _objectSpread(_objectSpread({}, item), {}, {
              tempServerId: targetItem.tempServerId
            });
          })
        }
      }).then(function (res) {
        if (res) {
          notification.success();

          _this5.handleFetchWebHook(targetItem);
        }
      });
    }
    /**
     * 滑窗取消操作
     */

  }, {
    key: "handleCancelOption",
    value: function handleCancelOption() {
      this.setState({
        drawerVisible: false,
        targetItem: {}
      });
    }
    /**
     * 改变租户，清空模板和服务
     */

  }, {
    key: "changeTenant",
    value: function changeTenant() {
      var dispatch = this.props.dispatch;
      dispatch({
        type: 'sendConfig/updateState',
        payload: {
          header: {
            serverList: []
          }
        }
      });
    }
    /**
     * 打开模板模态框
     * @param {object} record
     * @memberof Detail
     */

  }, {
    key: "openTemplateDrawer",
    value: function openTemplateDrawer(record) {
      var _this$props7 = this.props,
          dispatch = _this$props7.dispatch,
          tenantRoleLevel = _this$props7.tenantRoleLevel,
          _this$props7$sendConf = _this$props7.sendConfig.header,
          header = _this$props7$sendConf === void 0 ? {} : _this$props7$sendConf;
      var params = !tenantRoleLevel ? {
        tenantId: header.tenantId,
        templateCode: record.templateCode
      } : {
        templateCode: record.templateCode
      };
      dispatch({
        type: 'sendConfig/fetchTemplateData',
        payload: params
      });
      this.setState({
        templateDrawerVisible: true
      });
    }
    /**
     * 关闭模板模态框
     */

  }, {
    key: "closeTemplateDrawer",
    value: function closeTemplateDrawer() {
      this.setState({
        templateDrawerVisible: false
      });
    }
  }, {
    key: "handleCategoryCodeChange",
    value: function handleCategoryCodeChange(_, selectedOptions) {
      this.setState({
        categoryMeaning: selectedOptions[0] && selectedOptions[0].meaning,
        subcategoryMeaning: selectedOptions[1] && selectedOptions[1].meaning
      });
    }
    /**
     * render
     * @returns React.element
     */

  }, {
    key: "render",
    value: function render() {
      var _this$props8 = this.props,
          form = _this$props8.form,
          fetchTemplateLoading = _this$props8.fetchTemplateLoading,
          fetchHeaderLoading = _this$props8.fetchHeaderLoading,
          fetchWebHookLoading = _this$props8.fetchWebHookLoading,
          deleteWebHookLoading = _this$props8.deleteWebHookLoading,
          createLoading = _this$props8.createLoading,
          updateLoading = _this$props8.updateLoading,
          match = _this$props8.match,
          _this$props8$sendConf = _this$props8.sendConfig,
          _this$props8$sendConf2 = _this$props8$sendConf.header,
          header = _this$props8$sendConf2 === void 0 ? {} : _this$props8$sendConf2,
          _this$props8$sendConf3 = _this$props8$sendConf.messageType,
          messageType = _this$props8$sendConf3 === void 0 ? [] : _this$props8$sendConf3,
          _this$props8$sendConf4 = _this$props8$sendConf.copyDetail,
          copyDetail = _this$props8$sendConf4 === void 0 ? {} : _this$props8$sendConf4,
          _this$props8$sendConf5 = _this$props8$sendConf.templateData,
          templateData = _this$props8$sendConf5 === void 0 ? {} : _this$props8$sendConf5,
          _this$props8$sendConf6 = _this$props8$sendConf.categoryTree,
          categoryTree = _this$props8$sendConf6 === void 0 ? [] : _this$props8$sendConf6,
          webHook = _this$props8$sendConf.webHook,
          tenantRoleLevel = _this$props8.tenantRoleLevel,
          tenantId = _this$props8.tenantId,
          path = _this$props8.match.path,
          _this$props8$history$ = _this$props8.history.location.payload,
          payload = _this$props8$history$ === void 0 ? {} : _this$props8$history$;
      var isCopy = payload.isCopy;
      var _this$state2 = this.state,
          _this$state2$targetIt = _this$state2.targetItem,
          targetItem = _this$state2$targetIt === void 0 ? {} : _this$state2$targetIt,
          _this$state2$drawerVi = _this$state2.drawerVisible,
          drawerVisible = _this$state2$drawerVi === void 0 ? false : _this$state2$drawerVi,
          templateDrawerVisible = _this$state2.templateDrawerVisible;
      var headerTitle = _isUndefined(match.params.id) ? intl.get('cmsg.sendConfig.view.message.title.add').d('消息发送配置 - 添加') : intl.get('cmsg.sendConfig.view.message.title.edit').d('消息发送配置 - 编辑');
      var title = targetItem.tempServerId ? intl.get('cmsg.sendConfig.view.message.drawer.editTemplate').d('编辑模版') : intl.get('cmsg.sendConfig.view.message.drawer.addTemplate').d('添加模版');
      var getFieldDecorator = form.getFieldDecorator,
          getFieldValue = form.getFieldValue;
      var listProps = {
        path: path,
        messageType: messageType,
        loading: fetchHeaderLoading,
        dataSource: isCopy ? copyDetail.serverList : header.serverList,
        onEdit: this.handleEditContent,
        onDelete: this.handleDeleteContent,
        onOpen: this.openTemplateDrawer
      };
      var drawerProps = {
        title: title,
        path: path,
        messageType: messageType,
        webHook: webHook,
        tenantId: tenantRoleLevel ? tenantId : getFieldValue('tenantId'),
        ds: this.ds,
        anchor: 'right',
        visible: drawerVisible,
        itemData: targetItem,
        fetchLoading: fetchWebHookLoading,
        deleteLoading: deleteWebHookLoading,
        onOk: this.handleSaveContent,
        onCancel: this.handleCancelOption,
        onEditOk: this.handleEditOk,
        onAdd: this.handleAddWebHook,
        onDelete: this.handleDeleteWebHook,
        onFetch: this.handleFetchWebHook,
        onRef: this.getRef
      };
      var templateDrawerProps = {
        title: intl.get('cmsg.sendConfig.view.message.viewTemplate').d('查看模板'),
        anchor: 'right',
        content: templateData,
        loading: fetchTemplateLoading,
        visible: templateDrawerVisible,
        onClose: this.closeTemplateDrawer
      };
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, {
        title: isCopy ? intl.get('cmsg.sendConfig.view.message.title.add').d('消息发送配置 - 添加') : headerTitle,
        backPath: "/cmsg/send-config/list"
      }, /*#__PURE__*/React.createElement(ButtonPermission, {
        permissionList: [{
          code: "".concat(path, ".button.save"),
          type: 'button',
          meaning: '消息发送配置-保存'
        }],
        type: "primary",
        icon: "save",
        onClick: this.handleSave,
        loading: createLoading || updateLoading
      }, intl.get('cpaas.common.button.save').d('保存'))), /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(Card, {
        key: "send-config-header",
        bordered: false,
        className: DETAIL_CARD_CLASSNAME,
        title: /*#__PURE__*/React.createElement("h3", null, intl.get('cmsg.sendConfig.view.message.title').d('发送配置'))
      }, /*#__PURE__*/React.createElement(Form, {
        className: EDIT_FORM_CLASSNAME
      }, /*#__PURE__*/React.createElement(Row, EDIT_FORM_ROW_LAYOUT, /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, EDIT_FORM_ITEM_LAYOUT, {
        label: intl.get('cmsg.sendConfig.model.sendConfig.messageCode').d('消息代码'),
        required: _isUndefined(header.messageCode)
      }), getFieldDecorator('messageCode', {
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('cmsg.sendConfig.model.sendConfig.messageCode').d('消息代码')
          })
        }, {
          pattern: CODE_UPPER,
          message: intl.get('cpaas.common.validation.codeUpper').d('全大写及数字，必须以字母、数字开头，可包含“-”、“_”、“.”、“/”')
        }, {
          max: 30,
          message: intl.get('cpaas.common.validation.max', {
            max: 30
          })
        }],
        initialValue: isCopy ? copyDetail.messageCode : header.messageCode
      })(_isUndefined(header.messageCode) || isCopy ? /*#__PURE__*/React.createElement(Input, {
        trim: true,
        typeCase: "upper",
        inputChinese: false
      }) : /*#__PURE__*/React.createElement(React.Fragment, null, header.messageCode)))), /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({
        label: intl.get('cmsg.sendConfig.model.sendConfig.messageName').d('消息名称')
      }, EDIT_FORM_ITEM_LAYOUT), getFieldDecorator('messageName', {
        initialValue: isCopy ? copyDetail.messageName : header.messageName,
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('cmsg.sendConfig.model.sendConfig.messageName').d('消息名称')
          })
        }, {
          max: 120,
          message: intl.get('cpaas.common.validation.max', {
            max: 120
          })
        }]
      })( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({
        label: intl.get('cpaas.common.status.enable').d('启用')
      }, EDIT_FORM_ITEM_LAYOUT), getFieldDecorator('enabledFlag', {
        initialValue: _isUndefined(match.params.id) ? 1 : header.enabledFlag
      })( /*#__PURE__*/React.createElement(Switch, null)))), !tenantRoleLevel && /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, EDIT_FORM_ITEM_LAYOUT, {
        label: intl.get('entity.tenant.tag').d('租户'),
        required: _isUndefined(header.tenantId)
      }), getFieldDecorator('tenantId', {
        initialValue: header.tenantId,
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('entity.tenant.tag').d('租户')
          })
        }]
      })(_isUndefined(header.tenantId) ? /*#__PURE__*/React.createElement(Lov, {
        code: "CPFM.TENANT",
        textValue: header.tenantName,
        onChange: this.changeTenant
      }) : /*#__PURE__*/React.createElement(React.Fragment, null, header.tenantName)))), /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, EDIT_FORM_ITEM_LAYOUT, {
        label: intl.get('cmsg.sendConfig.model.sendConfig.messageType').d('消息类型')
      }), getFieldDecorator('categoryCode', {
        initialValue: [header.categoryCode, header.subcategoryCode]
      })( /*#__PURE__*/React.createElement(Cascader, {
        fieldNames: {
          label: 'meaning',
          value: 'value',
          children: 'children'
        },
        options: categoryTree,
        expandTrigger: "hover",
        placeholder: "",
        onChange: this.handleCategoryCodeChange
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_3_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, EDIT_FORM_ITEM_LAYOUT, {
        label: intl.get('cmsg.sendConfig.model.sendConfig.receiveConfigFlag').d('是否配置接收')
      }), getFieldDecorator('receiveConfigFlag', {
        initialValue: _isUndefined(match.params.id) ? 0 : header.receiveConfigFlag
      })( /*#__PURE__*/React.createElement(Switch, null))))), getFieldDecorator('tenantName', {
        initialValue: header.tenantName
      })( /*#__PURE__*/React.createElement("span", null)), getFieldDecorator('templateCode', {
        initialValue: header.templateCode
      })( /*#__PURE__*/React.createElement("span", null)))), /*#__PURE__*/React.createElement(Card, {
        key: "send-config-line",
        bordered: false,
        className: DETAIL_CARD_TABLE_CLASSNAME,
        title: /*#__PURE__*/React.createElement("h3", null, intl.get('cmsg.sendConfig.view.title.template').d('模板'))
      }, /*#__PURE__*/React.createElement("div", {
        className: "table-list-operator"
      }, /*#__PURE__*/React.createElement(ButtonPermission, {
        permissionList: [{
          code: "".concat(path, ".button.addTemplate"),
          type: 'button',
          meaning: '消息发送配置-添加模板'
        }],
        type: "primary",
        onClick: this.handleAddLine
      }, intl.get('cmsg.sendConfig.view.button.addTemplate').d('添加模板'))), /*#__PURE__*/React.createElement(ListTable, listProps)), drawerVisible && /*#__PURE__*/React.createElement(Drawer, drawerProps), /*#__PURE__*/React.createElement(TemplateDrawer, templateDrawerProps)));
    }
  }]);

  return Detail;
}(Component), (_applyDecoratedDescriptor(_class2.prototype, "handleSearch", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSearch"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleAddLine", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "handleAddLine"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleDataSetChange", [_dec6], Object.getOwnPropertyDescriptor(_class2.prototype, "handleDataSetChange"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleSave", [_dec7], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSave"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleEditContent", [_dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "handleEditContent"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleFetchWebHook", [_dec9], Object.getOwnPropertyDescriptor(_class2.prototype, "handleFetchWebHook"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "getRef", [_dec10], Object.getOwnPropertyDescriptor(_class2.prototype, "getRef"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleDeleteContent", [_dec11], Object.getOwnPropertyDescriptor(_class2.prototype, "handleDeleteContent"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleSaveContent", [_dec12], Object.getOwnPropertyDescriptor(_class2.prototype, "handleSaveContent"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleEditOk", [_dec13], Object.getOwnPropertyDescriptor(_class2.prototype, "handleEditOk"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleAddWebHook", [_dec14], Object.getOwnPropertyDescriptor(_class2.prototype, "handleAddWebHook"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleDeleteWebHook", [_dec15], Object.getOwnPropertyDescriptor(_class2.prototype, "handleDeleteWebHook"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleCancelOption", [_dec16], Object.getOwnPropertyDescriptor(_class2.prototype, "handleCancelOption"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "changeTenant", [_dec17], Object.getOwnPropertyDescriptor(_class2.prototype, "changeTenant"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "openTemplateDrawer", [_dec18], Object.getOwnPropertyDescriptor(_class2.prototype, "openTemplateDrawer"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "closeTemplateDrawer", [_dec19], Object.getOwnPropertyDescriptor(_class2.prototype, "closeTemplateDrawer"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleCategoryCodeChange", [_dec20], Object.getOwnPropertyDescriptor(_class2.prototype, "handleCategoryCodeChange"), _class2.prototype)), _class2)) || _class) || _class) || _class);
export { Detail as default };